#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdbool.h>

/*bool isPerfectSquare(int num){
    int ret = sqrt(num);
    if(ret*ret==num)
    return true;
    else
    return false;
}*/
bool isPerfectSquare(int num) {
    int left = 1;
    int right = num;
    long long mid = 0;
    while (left <= right)
    {
        mid = left + (right - left) / 2;
        long long tmp = mid * mid;
        if (tmp < num)
        {
            left = mid + 1;
        }
        else if (tmp > num)
        {
            right = mid - 1;
        }
        else
        {
            return true;
        }
    }
    return false;
}
int cmp(const void* e1, const void* e2)
{
    return *(int*)e1 - *(int*)e2;
}
int findTheDistanceValue(int* arr1, int arr1Size, int* arr2, int arr2Size, int d) {
    int count = 0;
    qsort(arr2, arr2Size, sizeof(int), cmp);
    for (int i = 0; i < arr1Size; i++)
    {
        int left = 0;
        int right = arr2Size - 1;
        while (left <= right)
        {
            int mid = left + (right - left) / 2;
            if (arr2[mid] < arr1[i] - d)
            {
                left = mid + 1;
            }
            else if (arr2[mid] > arr1[i] + d)
            {
                right = mid - 1;
            }
            else
            {
                break;
            }
        }
        if (left > right)
            count++;
    }
    return count;
}

int main()
{
    bool ret = isPerfectSquare(16);
    printf("%d\n", ret);
    return 0;
}